#include<iostream>
#include"functions.h"

using namespace std;

int main()
{
  int n = 100;
  double** A = new double*[n];
  double* b = new double[n];
  double tmp = 0.0;
  for(int i = 0; i < n; i++)
    {
      tmp = 0.0;
      A[i] = new double[n]();
      for(int j = 0; j < n; j++)
	{
	  A[i][j] = 1.0/(i+j+3.0);
	  tmp += A[i][j];
	}
      b[i] = tmp/3.0;	
    }
  double* x = new double[n]();
  ConjugateGradient(A, b, x, n);
  for(int i = 0; i < n; i++)
    cout << "x[" << i+1 << "] = " <<  x[i] << endl;
  for(int i = 0; i < n; i++)
    x[i] = x[i] - 1.0/3.0;
  cout << Norm_Vector_2(x, n) << endl;
  for(int i = 0; i < n; i++)
    delete [] A[i];
  delete [] A;
  delete [] x;
  delete [] b;
  
    
   
  return 0;
};
